package org.third.spring.boot.hello.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.third.spring.boot.hello.domain.HelloUser;
import org.third.spring.boot.hello.repository.HelloUserRepository;

import java.util.ArrayList;
import java.util.List;

@Component
public class HelloUserService {
	@Autowired
	HelloUserRepository helloUserRepository;

	public String getUser() {
		return "Hello ,spring boot!";
	}

	public List<HelloUser> listUsers() {
		Iterable<HelloUser> userIterator = helloUserRepository.findAll();
		List<HelloUser> users = new ArrayList<HelloUser>();
		userIterator.spliterator().tryAdvance(c -> {
			users.add(c);
		});
		// helloUserRepository.findByUuid(uuid);
		return users;
	}
}
